<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${element.packagePath!}.${element.mapperPackageName!}.${element.beanName!}Mapper">


    <!--分页查询-->
    <select id="${element.beanCaseName!}QueryPage" resultType="${element.packagePath!}.${element.beanPackageName!}.${element.beanName!}Entity">
        select
            <#list  element.fields as item>
                ${item!} <#if element.fieldSize!=item_index>,</#if>
            </#list>
        from ${element.tableName!} t1
        where 1=1
        <#list element.queryConditions as query>
            <#if query.isQuery==1>
                <if test="queryBean.${query.beanField!} !=null <#if query.fieldType == "String"> and queryBean.${query.beanField} !=''</#if> ">

                        <#if query.queryType == "like" >
                            <bind name="likeQuery" value="'%'+queryBean.${query.beanField}+'%'"/>
                            and t1.${query.fieldName!} like ${r'#{likeQuery}'}
                        <#else>
                            and t1.${query.fieldName!}=queryBean.${query.beanField!}
                        </#if>

                </if>
            </#if>
        </#list>
    </select>
    <!--查询详情-->
    <select id="get${element.beanName!}ById" resultType="${element.packagePath!}.${element.beanPackageName!}.${element.beanName!}Entity">
        select
            <#list element.fields as item>
            ${item!} <#if element.fieldSize!=item_index>,</#if>
            </#list>
        from ${element.tableName!} t1
        where id = ${r'#{id}'}
    </select>



</mapper>
